<template>
  <page class="product-detail">
    <v-back />
    <div class="flex-group">
      <div class="detail-group">
        <div class="bank-logo">
          <img :src="showImg(info.url)" alt="" />
        </div>
        <p class="bank-name">{{ info.name }}</p>
        <span class="price">最高{{ info.quantityMax }}万</span>
        <div class="line"></div>
        <div class="detail-group">
          <div class="detail-item">
            <img src="~@/assets/images/interest.png" class="item-icon" />
            <span>年化利率：{{ info.costMin }}~{{ info.costMax }}</span>
          </div>
          <div class="detail-item">
            <img src="~@/assets/images/method.png" class="item-icon" />
            <span v-if="info.repayType">还款方式：{{ info.repayType }}</span>
          </div>
          <div class="detail-item">
            <img src="~@/assets/images/term.png" class="item-icon" />
            <span>期限：{{ info.loansTime }}期</span>
          </div>
        </div>
        <van-tabs
          v-model="active"
          sticky
          animated
          color="#1677FF"
          title-active-color="#1677FF"
          offset-top="50"
        >
          <van-tab title="产品介绍">
            <div
              style="padding: 20px; line-height: 25px"
              v-html="info.description"
            ></div>
          </van-tab>
          <van-tab title="申请条件">
            <div
              style="padding: 20px; line-height: 25px"
              v-html="info.applyCondition"
            ></div>
          </van-tab>
          <!-- <van-tab title="办理流程">
                        <div style="padding: 20px;line-height:25px;" v-html="info.processContent"></div>
                    </van-tab> -->
        </van-tabs>
      </div>
      <a
        href="javascript: void (0)"
        class="a-btn"
        @click="$router.push(`/apply/${$route.params.id}`)"
        >申请贷款</a
      >
    </div>
  </page>
</template>

<script>
export default {
  name: "detail",
  data() {
    return {
      active: 0,
      info: {},
    };
  },

  created() {
    this.getInfo();
  },

  methods: {
    async getInfo() {
      this.$loading();
      const { data } = await this.$http.post(
        `/product/detail?id=${this.$route.params.id}`
      );
      this.info = data;
      this.$loading.close();
    },
  },
};
</script>

<style scoped lang="less">
.product-detail {
  .flex-group {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .detail-group {
    flex: 1;
    overflow-y: auto;
    .bank-logo {
      height: 1.2rem;
      border-radius: 6px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0 auto 0;

      img {
        height: 1.2rem;
      }
    }

    .bank-name {
      margin: 10px auto 0;
      font-size: @md;
      font-weight: 700;
      text-align: center;
      color: #666;
    }

    .price {
      text-align: center;
      display: block;
      margin: 6px auto;
      font-size: @big;
      font-weight: 700;
      color: @price-color;
    }

    .line {
      background: @border-color;
      height: 1px;
      margin: 0 @padding;
    }

    .detail-group {
      padding: @padding*2;

      .detail-item {
        display: flex;
        align-items: center;

        .item-icon {
          width: 30px;
          height: 30px;
        }

        span {
          margin-left: @padding;
        }

        &:not(:last-child) {
          margin-bottom: 10px;
        }
      }
    }
  }
}
</style>
<style lang="less">
.van-tab.van-tab--active {
  span {
    color: #1677ff;
  }
}
</style>
